メインコンテンツまでスキップ
バージョン: DAI 7.3

Using Submodels in Eggplant DAI

When you are modeling large or complex applications and systems, it might be useful to take a modular approach to creating your models. To facilitate modularization, Eggplant DAI lets you use submodels. A submodel is a model that you connect to an action of another model in the same way you connect code snippets. In this way, you can build large models out of smaller, modularized pieces.

Working with Submodels

As you build your models, you might focus on individual sections or subsystems of your applications in order to slowly build up the total picture of what you need to test. If you take this approach from the start, it should be easy to see how you might employ submodels in Eggplant DAI to bring together all the pieces of your application.

With this approach, you can test sections of your application independently, and also bring the independent models together into a top-level model for comprehensive testing by linking the section models as submodels. Linking submodels within actions allow you to define a hierarchy of different levels of model to describe your application. When selecting actions to execute, Eggplant DAI’s path selection algorithm considers paths in the submodel that haven’t been traversed yet.

Link a Submodel to a Model Action

You can use any model as a submodel as long as you have access to it.

When you edit a model, all the models that are available as submodels are listed in the Submodels tab. To narrow the number of models that are displayed, simply type a model name in the filter box.

To add a model as a submodel:

  1. With the Submodels tab selected, on the model, select the action to which you want to connect a submodel.
  2. On the Submodels tab, click the arrow next to the model name that you want to connect.

Each action has two dots in the upper-left corner. The right dot turns green when a submodel is attached. The left dot indicates if a snippet is attached. If you hover your cursor over a green dot, a tooltip shows what snippet or submodel is attached.

An Eggplant DAI action with an attached submodel shows a green dot on the right

You can connect both snippets and submodels to the same action. When both snippets and submodels are attached to an action, snippets run first, followed by submodels.

Run a Test with a Submodel

The process of running a test with a submodel is no different from any other test execution in Eggplant DAI. When you click Run on the toolbar, and you choose options for the model run, the model begins with the initial state and chooses a path through the model. When it selects an action that has a submodel attached, the execution switches to that secondary model.

In the console, you can see that the model has called the submodel, and what steps are performed there. The model view, however, doesn't change—it still shows the single highlighted action that called the submodel.

Important

When executed through a parent model, submodels will use the same suite as the parent model.

After the submodel completes successfully, execution of the parent model resumes from that point, just as it would for an attached snippet.

If you want to exclude the submodel from test execution, select Disabled in the Action Properties tab.

Select this checkbox to disable submodels

You also can include submodels in directed test cases.

Using Parameters with Submodels

You can pass parameter values between submodels and the parent model. You might use this capability to set a specific path within the submodel, for example. Or you could use a returned value to check whether a certain state or action in the submodel was hit during execution.

You need to define the parameter as a global parameter in both the parent model and the submodel. That is, the parameter name and definition must match in both models. Such parameters can be created just like any other global parameter. With no state or action selected, choose one of these options:

  • Right-click in the model workspace, then select New Parameter.
  • On the Global Properties tab in the right sidebar, click New in the Global Parameters section.

The new parameter appears as a line in the Global Parameters section with a default name. You can click in the fields to customize the Name, Type, Generation method, and Initial Value, as necessary.

Remember that you need to create the parameter in both the parent model and the submodel.

After you create your parameters, in the parent model, you need to associate them with the submodel:

  1. Select an action in the workspace where you have an attached submodel.

  2. In the Submodels Called by Action section of the Action Properties tab in the right pane, right-click the attached submodel and select Edit Passthrough Parameters.

    Right-click a submodel in the Submodels Called by Action section to associate the parameters you want to pass to an Eggplant AI submodel

  3. In the Submodel I/O Editor dialog box, select the checkbox in the selected column for any parameter you want to pass between the submodel and the parent model. Click OK to close the dialog box and save your selections.

ノート

If the parameter you pass into a submodel has a value, that value overwrites any initial value that might be set for the parameter in the submodel.

If a parameter value is updated during the submodel run and passed back to the parent model, the new value overwrites the parameter in the parent model when the submodel exits.